package ac.github.os.internal.core.condition.impl.location

import ac.github.os.internal.core.condition.Condition
import ac.github.os.internal.core.condition.call
import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import ac.github.os.internal.core.trigger.LocationTrigger
import ac.github.os.internal.core.trigger.PlayerTrigger
import ac.github.os.internal.session.Session
import taboolib.common.platform.Awake

@Awake
class WorldCondition : Condition {

    override fun doScreen(session: Session, config: StringConfig): Boolean {
        return session.call<LocationTrigger> { trigger ->

            val arrayOfAnys = config.get<Array<Any>>("array", single = true) ?: return false
            return arrayOfAnys.map { it.toString() }.any { trigger.location.world?.name == it }
        }
    }

    override val namespace: String
        get() = "world"
}